package com.example.neusoft215gdh.androidpro_21.Activity;


import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.neusoft215gdh.androidpro_21.Fragement.BaseActivity;
import com.example.neusoft215gdh.androidpro_21.Interface.YuejianService;
import com.example.neusoft215gdh.androidpro_21.JavaBean.GuanyuYuejian;
import com.example.neusoft215gdh.androidpro_21.R;
import com.squareup.picasso.Picasso;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class GuanyuYuejianActivity extends BaseActivity {
private ImageView loge;
    private ImageButton back;
    private TextView yuejian_name,coent;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guanyu_yuejian);
        loge= (ImageView) findViewById(R.id.yuejian_loge);
        back= (ImageButton) findViewById(R.id.yuejian_back);
        yuejian_name= (TextView) findViewById(R.id.yuejian_name);
        coent= (TextView) findViewById(R.id.conent_yuejian);

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("http://172.24.10.175/workout/api.php/")
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        YuejianService yuejianService =retrofit.create(YuejianService.class);
        Call<GuanyuYuejian> listCall = yuejianService.yuejian(userId);
       listCall.enqueue(new Callback<GuanyuYuejian>() {
           @Override
           public void onResponse(Call<GuanyuYuejian> call, Response<GuanyuYuejian> response) {
               GuanyuYuejian guanyuYuejian =response.body();

               if (com.example.neusoft215gdh.androidpro_21.Activity.GuanyuYuejianActivity.this != null) {

                   if (guanyuYuejian.getLogo() != "") {
                       Picasso.with(com.example.neusoft215gdh.androidpro_21.Activity.GuanyuYuejianActivity.this).load("http://172.24.10.175/workout/Uploads/"+guanyuYuejian.getLogo()).error(R.drawable.yuejian)
                               .into(loge);
                   }
                   yuejian_name.setText(guanyuYuejian.getCorpname());
                   coent.setText(guanyuYuejian.getContact());
               }
           }

           @Override
           public void onFailure(Call<GuanyuYuejian> call, Throwable t) {

           }
       });










        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });


    }
}
